﻿using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Catel.Data;

namespace Catel.Articles._03___MVVM.Models
{
    /// <summary>
    /// House Data object class which fully supports serialization, property changed notifications,
    /// backwards compatibility and error checking.
    /// </summary>
    [Serializable]
    public class House : DataObjectBase<House>
    {
        #region Variables
        #endregion

        #region Constructor & destructor
        /// <summary>
        /// Initializes a new object from scratch.
        /// </summary>
        public House()
        {
            // Create collections
            Rooms = new ObservableCollection<Room>();
        }

        /// <summary>
        /// Initializes a new object based on <see cref="SerializationInfo"/>.
        /// </summary>
        /// <param name="info"><see cref="SerializationInfo"/> that contains the information.</param>
        /// <param name="context"><see cref="StreamingContext"/>.</param>
        protected House(SerializationInfo info, StreamingContext context)
            : base(info, context) { }
        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name
        {
            get { return GetValue<string>(NameProperty); }
            set { SetValue(NameProperty, value); }
        }

        /// <summary>
        /// Register the Name property so it is known in the class.
        /// </summary>
        public static readonly PropertyData NameProperty = RegisterProperty("Name", typeof(string), "House");

        /// <summary>
        /// Gets or sets the collection of rooms.
        /// </summary>
        public ObservableCollection<Room> Rooms
        {
            get { return GetValue<ObservableCollection<Room>>(RoomsProperty); }
            set { SetValue(RoomsProperty, value); }
        }

        /// <summary>
        /// Register the Rooms property so it is known in the class.
        /// </summary>
        public static readonly PropertyData RoomsProperty = RegisterProperty("Rooms", typeof(ObservableCollection<Room>));
        #endregion

        #region Methods
        #endregion
    }
}
